package com.mzz.structure.proxy.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author xushijian
 * @date 18/6/4 下午12:21
 */
public class PersonHandler implements InvocationHandler {

    /**
     * 被代理的对象
     */
    private Object target;

    public PersonHandler(Object target) {
        this.target = target;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println("before ...");

        Object result = method.invoke(target, args);

        System.out.println("after ....");

        return result;
    }
}
